package com.wjh.kt_vod.controller;

import com.wjh.kt_vod.model.vod.Subject;
import com.wjh.kt_vod.result.Result;
import com.wjh.kt_vod.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "课程分类查询")
@RestController
@RequestMapping("/admin/vod/subject")
public class SubjectController {

    @Autowired
    @Qualifier("subjectServiceImpl")
    private SubjectService subjectService;

    @ApiOperation(value = "课程分类列表")
    @GetMapping("/getChildSubject/{id}")
    public Result getChildSubject(@PathVariable("id") Long id){
        List<Subject> subjects = subjectService.selectChildSubject(id);
        return Result.ok(subjects);
    }

    @ApiOperation(value = "导出课程")
    @GetMapping("/exportData")
    public Result exportExcel(HttpServletResponse httpServletResponse){
        subjectService.exportData(httpServletResponse);
        return Result.ok().message("导出成功");
    }

    @ApiOperation(value = "导入课程")
    @PostMapping("/importData")
    public Result importExcel(MultipartFile multipartFile){
        subjectService.importData(multipartFile);
        return Result.ok().message("导入成功");
    }




}
